<?php
namespace Home\Controller;

use Util\AccessController;

class ZnSelectBookController extends AccessController {

    /*
     * 获取智能选书key
     */
    public function GetKey() {
        $files = 'region_name';
        $LS = Service('ZnSelectBook', 'region');
        $pdata = $LS->find(array('region_name' => '智能选书主题'));
        $sondata = $LS->query(array('region_fid' => $pdata['region_id']), null, $files);
        $temp['list'] = $sondata;
        $temp['title'] = '主题';
        $temp['limit'] = 3;
        $data[] = $temp;

        $pdata = $LS->find(array('region_name' => '智能选书奖项'));
        $sondata = $LS->query(array('region_fid' => $pdata['region_id']), null, $files);
        $temp['list'] = $sondata;
        $temp['title'] = '奖项';
        $temp['limit'] = 1;
        $data[] = $temp;

        $pdata = $LS->find(array('region_name' => '智能选书大师'));
        $sondata = $LS->query(array('region_fid' => $pdata['region_id']), null, $files);
        $temp['list'] = $sondata;
        $temp['title'] = '大师';
        $temp['limit'] = 1;
        $data[] = $temp;

        $pdata = $LS->find(array('region_name' => '智能选书年龄段'));
        $sondata = $LS->query(array('region_fid' => $pdata['region_id']), null, $files);
        $temp['list'] = $sondata;
        $temp['title'] = '年龄段';
        $temp['limit'] = 1;
        $data[] = $temp;

        $pdata = $LS->find(array('region_name' => '智能选书显示数'));
        $sondata = $LS->query(array('region_fid' => $pdata['region_id']), null, $files);
        $temp['list'] = $sondata;
        $temp['title'] = '选择本数';
        $temp['limit'] = 1;
        $data[] = $temp;

        $DATA = ResData($data);
        $this->ajaxReturn($DATA);
    }

}